package ch.ethz.eai.data;

/**
 * Represents a physical location.
 * <br>
 * Either the longtitude and latitude pair, or the rest of the address has to be filled in at all times.
 * @author zistvan
 *
 */
public class Location {

	private double longtitude = 0;
	private double latitude = 0;
	private String streetAddress = "";
	private String town = "";
	private String postalCode = "";
	private String country = "";
	
	
	public Location(double longtitude, double latitude) {
		this.longtitude = longtitude;
		this.latitude = latitude;
	}


	public Location(String streetAddress, String town, String postalCode,
			String country) {
		super();
		this.streetAddress = streetAddress;
		this.town = town;
		this.postalCode = postalCode;
		this.country = country;
	}

		
	
	public Location(double longtitude, double latitude, String streetAddress,
			String town, String postalCode, String country) {
		super();
		this.longtitude = longtitude;
		this.latitude = latitude;
		this.streetAddress = streetAddress;
		this.town = town;
		this.postalCode = postalCode;
		this.country = country;
	}


	public Location(String town, String country) {
		this.town = town;	this.country = country;
		
	}


	public double getLongtitude() {
		return longtitude;
	}


	public void setLongtitude(double longtitude) {
		this.longtitude = longtitude;
	}


	public double getLatitude() {
		return latitude;
	}


	public void setLatitude(double latitude) {
		this.latitude = latitude;
	}


	public String getStreetAddress() {
		return streetAddress;
	}


	public void setStreetAddress(String streetAddress) {
		this.streetAddress = streetAddress;
	}


	public String getTown() {
		return town;
	}


	public void setTown(String town) {
		this.town = town;
	}


	public String getPostalCode() {
		return postalCode;
	}


	public void setPostalCode(String postalCode) {
		this.postalCode = postalCode;
	}


	public String getCountry() {
		return country;
	}


	public void setCountry(String country) {
		this.country = country;
	}
	
	public boolean hasCoordinates() {
		return latitude!=0 && longtitude!=0;
	}
	
	
	@Override
	public String toString() {
		return ("Long:"+longtitude+" Lat:"+latitude+" Addr:"+streetAddress+" Town:"+town+" PC:"+postalCode+" Country:"+country);
	}

	public boolean hasAddress() {
		return (streetAddress!=null && streetAddress.length()>0) && ((postalCode!=null && postalCode.length()>0) || (town!=null && town.length()>0)) && (country!=null && country.length()>0);
	}
	
	
}
